/*
** transfer.c for  in /home/gomes_m//my-project-a-moi/server
** 
** Made by mickael gomes
** Login   <gomes_m@epitech.net>
** 
** Started on  Sun Jul 28 13:13:13 2013 mickael gomes
** Last update Wed Jul 31 00:03:10 2013 mickael gomes
*/

#include			<stdio.h>
#include			<sys/types.h>
#include			<sys/stat.h>
#include			<fcntl.h>
#include			"struct.h"
#include			"prototypes.h"

void				get_file(t_list *list)
{
  int				fd;
  int				len;
  char				*buff;

  buff = xmalloc(MAX_SIZE * sizeof(char));
  if ((fd = open(list->cmd->arguments, O_RDONLY)) == -1)
    {
      my_putstr(2, "Open has failed.\n", 0);
      my_putstr(list->fd, "Open has failed.\n", 0);
      return ;
    }
  xread(fd, buff, MAX_SIZE);
  len = xwrite(list->fd, buff, my_strlen(buff));
  if (len != my_strlen(buff))
    xwrite(list->fd, &buff[len], my_strlen(buff) - len);
}
